﻿using System;
using System.Collections.Generic;

namespace RESTController
{
    public class FakeResourceController : ResourceController<FakeModel>
    {
        public bool DeleteShouldThrowException { get; set; }

        protected override object AddModel(FakeModel model)
        {
            var rand = new Random();
            return rand.Next();
        }

        protected override void DeleteModel(object id)
        {            
            if (DeleteShouldThrowException)
            {
                throw new InvalidOperationException("Delete is throwing an exception.");
            }
        }

        protected override FakeModel GetModel(object id)
        {
            return new FakeModel { Id = Convert.ToInt32(id), Name = "Say my name" };
        }

        protected override IEnumerable<FakeModel> GetModels()
        {
            return new List<FakeModel>();
        }

        protected override void SaveModel(FakeModel model)
        {
            throw new NotImplementedException();
        }
    }
}
